﻿// Decompiled by AS3 Sorcerer 6.78
// www.buraks.com/as3sorcerer

//com.wdcgame.tile.utils.TMXResource

package com.game.tile.utils
{
    import flash.utils.Dictionary;
    import flash.display.LoaderInfo;
    import flash.display.BitmapData;

    public class TMXResource 
    {

        private var _tileBds:Dictionary = new Dictionary();
        private var _imgs:Dictionary = new Dictionary();
        private var _tmx:XML;
        private var loaderInfo:LoaderInfo;

        public function TMXResource(_arg_1:XML)
        {
            this._tmx = _arg_1;
        }

        public function AddResBySwf(_arg_1:LoaderInfo):void
        {
            this.loaderInfo = _arg_1;
        }

        public function AddImage(_arg_1:String, _arg_2:BitmapData):void
        {
            _imgs[_arg_1] = _arg_2;
        }

        public function GetResClass(_arg_1:String):Class
        {
            return (loaderInfo.applicationDomain.getDefinition(_arg_1) as Class);
        }

        public function AddTileBitmapData(_arg_1:String, _arg_2:BitmapData):void
        {
            _tileBds[_arg_1] = _arg_2;
        }

        public function getTileBdByName(_arg_1:String):BitmapData
        {
            var _local_2:* = null;
            if (loaderInfo)
            {
                if (!_imgs[_arg_1])
                {
                    _local_2 = GetResClass(_arg_1);
                    _tileBds[_arg_1] = new (_local_2)();
                }
            }
            return (_tileBds[_arg_1]);
        }

        public function getImageByName(_arg_1:String, _arg_2:String):Object
        {
            var _local_3:* = null;
            var _local_4:* = _arg_1;
            if (!_imgs[_local_4])
            {
                if (loaderInfo)
                {
                    try
                    {
                        _local_3 = GetResClass(_arg_1);
                        _imgs[_arg_1] = _local_3;
                    }
                    catch(error:Error)
                    {
                        _local_3 = GetResClass(_arg_2);
                        _imgs[_arg_2] = _local_3;
                        _local_4 = _arg_2;
                    }
                }
            }
            return (_imgs[_local_4]);
        }

        public function get tmx():XML
        {
            return (_tmx);
        }

        public function destroy():void
        {
            loaderInfo = null;
            _tmx = null;
            _tileBds = null;
            _imgs = null;
        }


    }
}//package com.wdcgame.tile.utils

